package demo.hw;

import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

/**
 * 输入
 * 4
 * 0 1
 * 0 2
 * 1 2
 * 3 4
 * 输出
 * 0 3
 * 1 2
 * 3 4
 *
 * @author taqo
 * @date 2021/5/25
 */
public class _合并表记录 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer,Integer> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            int v = sc.nextInt();
            Integer nm = map.get(k);
            if (nm == null) {
                map.put(k,v);
            } else {
                map.put(k,nm+v);
            }
        }
        System.out.println(map);
    }
}
